package org.kwisatz.proxybot;

import java.io.PrintWriter;

/**
 * Various method to help writing IRC messages 
 */
public class Toolkit
{
	/**
	 * Write a message to a channel, on both server and client side
	 * @param context
	 * @param channel
	 * @param message
	 */
	static public PrintWriter channelWriter(final Context context, final String channel)
	{
		final String prefix= ':' +context.getNickName()+"!proxybot@localhost PRIVMSG "+channel+" :";
		return new PrintWriter(context.getServer())
		{
			public void println(String x)
			{
				context.getServer().println("PRIVMSG "+channel+" :"+x);
				context.getClient().println(prefix+x);
			}
		};
	}
}
